<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="vue.js"></script>
</head>
<body>
  <div id="app">
    <my-parent></my-parent>
  </div>
  <template id="father">
    <div>
      {{ value }}
      <my-son @click-event="getData"></my-son>
    </div>
  </template>

  <template id="son">
    <div>
      子组件
      <button @click="sendData">发送数据</button>
    </div>
  </template>
</body>
<script>
  const Son = {
    template: '#son',
    methods: {
      sendData(){
        this.$emit('click-event', 10)
      }
    }
  }

  const Father = {
    template: '#father',
    data() {
      return {
        value:''
      }
    },
    components: {
      'mySon': Son
    },
    methods:{
      getData(val) {
        console.log(this.value);
        this.value = val;
        console.log(this.value);
      }
    }
  }

  new Vue({
    el: '#app',
    components: {
      'myParent': Father
    }
  })
</script>
</html>